package ruifeng.zcj.mybase.base;

import android.content.Context;

import java.lang.ref.WeakReference;


/**
 * Created by Administrator on 2016/8/15 0015.
 */
public abstract class BasePresenter<E, T> {
    public Context mContext;
    public E mModel;
    protected WeakReference<T> weakReference;
    public RxManager mRxManager = new RxManager();
    public void setVM(T v, E m) {
        weakReference = new WeakReference<T>(v);
        this.mModel = m;
        this.onStart();
    }
    public T getView(){
        return weakReference.get();
    }
    public abstract void onStart();

    public void onDestroy() {
        if (weakReference != null){
            weakReference.clear();
            weakReference = null;
        }
        mRxManager.clear();
    }

}
